import request from "@/utils/request";

const LOG_BASE_URL = "/v3/manager/point";

class PointApi {
  /**
   * 添加设备类型
   *
   * @param queryParams 查询参数
   */
  static savePointItem(queryParams: pointItemList) {
    return request({
      url: `${LOG_BASE_URL}/savePointItem`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 添加设备类型
   *
   * @param queryParams 查询参数
   */
  static addDevType(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/save`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 获取日志分页列表
   *
   * @param queryParams 查询参数
   */
  static getPage(queryParams: LogPageQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/page`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 获取设备类型分页列表
   *
   * @param queryParams 查询参数
   */
  static getFences(queryParams: FencesPageQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/page`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }

  /**
   * 编辑设备类型
   *
   * @param queryParams 查询参数
   */
  static editSave(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/update`,
      method: "put",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 删除设备类型
   *
   * @param queryParams 查询参数
   */
  static deleteSave(queryParams: number) {
    return request({
      url: `${LOG_BASE_URL}/delete/${queryParams}`,
      method: "delete",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
    });
  }
}

export default PointApi;

/**
 * 日志分页查询对象
 */
export interface LogPageQuery {
  /** 搜索关键字 */
  pages?: any;
  pointName?: string;
  pointCode?: string;
  pointTypeFlag?: string;
  rwFlag?: string;
  deviceTypeId?: number | string;
  enableFlag?: string;
  pointGroupId: string;
}
/**
 * 分页VO
 */
export interface LogPageVO {
  current: number;
  pages: number;
  records: Array<any>;
  size: number;
  total: number;
}

/**
 * 电子围栏分页
 */
export interface FencesPageQuery {
  /** 搜索关键字 */
  pages?: any;
  fenceName?: string;
  customerId?: number;
}

/**
 * 添加电子围栏
 */
export interface addFencesPageQuery {
  /** 搜索关键字 */
  id?: string;
  fenceName: string;
  customerId: string;
  coordinateSet: Array<any>;
}

/**
 * 设备类型
 */
export interface DeviceTypeReq {
  /** 搜索关键字 */
  id?: string;
  pointName?: string;
  pointCode: string;
  pointTypeFlag: string;
  baseValue?: number;
  multiple?: number;
  valueDecimal?: string;
  unit?: string;
  deviceTypeId: number | string;
  enableFlag?: string;
  remark?: string;
  groupId: string;
  displayTypeFlag?: string;
  displayTypeItem?: string;
}
export interface pointItemList {
  pointId: string;
  itemList: any;
}
